package com.itheima.Demo01.demo01;

import java.io.File;
import java.util.HashMap;

public class Test03  {
    public static void main(String[] args) {
        File file = new File("D:\\soft\\day0610-code\\day0610-code");
        HashMap<String,Integer> map = new HashMap<>();
        getmap(map,file);
        System.out.println(map);

    }

    private static void getmap( HashMap<String, Integer> map,File file)  {
        File[] files = file.listFiles();

        for (File file1 : files) {
            if (file1.isFile()){
                String name = file1.getName();
                String[] split = name.split("\\.");
                if (split.length==2){
                    String s = split[1];
                    if (map.containsKey(s)){
                        Integer count = map.get(s);
                        count++;
                        map.put(s,count);
                    }else {
                        map.put(s,1);
                    }
                }
            }else {
                getmap(map,file1);
            }
        }
    }
}
